package com.kingint.web.admin.base.service.impl;

import com.kingint.mbg.bas.entity.BasIdentity;
import com.kingint.mbg.bas.mapper.BasIdentityMapper;
import com.kingint.mbg.sys.entity.UmsMember;
import com.kingint.mbg.sys.mapper.UmsMemberMapper;
import com.kingint.web.admin.base.service.BasIdentityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kingint.web.sys.service.UmsAdminService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.Date;

/**
 * <p>
 * 员工身份表 服务实现类
 * </p>
 *
 * @author wxh
 * @since 2020-12-23
 */
@Service
@Slf4j
public class BasIdentityServiceImpl extends ServiceImpl<BasIdentityMapper, BasIdentity> implements BasIdentityService {

    @Resource
    private UmsAdminService adminService;
    @Resource
    private UmsMemberMapper memberMapper;
    @Override
    public Boolean saves(BasIdentity basIdentity) {
        UmsMember currentMember = adminService.getCurrentMember();
        Integer hotelId = currentMember.getHotelId();//对应的酒店id
        if(StringUtils.isEmpty(hotelId)){
            log.debug("当前账号没有关联对应的酒店");
            return false;
        }
        basIdentity.setHotelId(hotelId);
        basIdentity.setCreateTime(new Date());
        boolean save = this.save(basIdentity);
        return save;
    }

    @Override
    public Boolean updateByIds(BasIdentity basIdentity) {
        return null;
    }
}
